//
//  ChangeLoginPWTableViewCell.m
//  GLGW_Shoping
//
//  Created by yang on 2018/11/28.
//  Copyright © 2018年 yang. All rights reserved.
//

#import "ChangeLoginPWTableViewCell.h"

@interface ChangeLoginPWTableViewCell ()
@property (nonatomic,strong)GLGWTextField * inputTextField;
@end

@implementation ChangeLoginPWTableViewCell{
    GLGWButton * seePasswordBut;
}

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        [self setSepartionLineWith:lineModel_Half];
        self.inputTextField = [[GLGWTextField alloc] initTitlePlaceholder:@"" theFont:SYSTEMFONT(14) theTitColor:kColor_Rule_Black inSuperView:self.contentView];
        [self.inputTextField mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.contentView.mas_left).offset(kWidthProportion_In_iPhoneTriploid(15));
            make.top.bottom.equalTo(self.contentView).offset(0);
            make.right.equalTo(self.contentView.mas_right).offset(-kWidthProportion_In_iPhoneTriploid(45));
        }];
        self.inputTextField.clearButtonMode=UITextFieldViewModeWhileEditing;
        self.inputTextField.delegate = nil;
        self.inputTextField.secureTextEntry = YES;
        [self.inputTextField addTarget:self action:@selector(textField1TextChange:) forControlEvents:UIControlEventEditingChanged];
        //
        seePasswordBut = [[GLGWButton alloc] initInSuperView:self.contentView];
//        seePasswordBut.backgroundColor = kRandomColor;
        seePasswordBut.hidden = YES;
        seePasswordBut.image_Name = @"myinfor_noSee";
        [seePasswordBut mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.inputTextField.mas_right).offset(0);
            make.right.equalTo(self.contentView.mas_right).offset(-kWidthProportion_In_iPhoneTriploid(5));
            make.top.equalTo(self.contentView.mas_top).offset(kHeightProportion_In_iPhoneTriploid(4));
            make.bottom.equalTo(self.contentView.mas_bottom).offset(-kHeightProportion_In_iPhoneTriploid(4));
        }];
        [seePasswordBut addTarget:self action:@selector(showPassword:) forControlEvents:UIControlEventTouchUpInside];
    }
    return self;
}

-(void)setRow_Num:(NSInteger)row_Num{
    _row_Num = row_Num;
    switch (_row_Num) {
        case 0:{
            self.inputTextField.placeholder = @"旧密码";
        }
            break;
        case 1:{
            self.inputTextField.placeholder = @"新密码";
        }
            break;
        case 2:{
            self.inputTextField.placeholder = @"重复新密码";
        }
            break;
            
        default:
            break;
    }
}
-(void)setChangeMarkModel:(AdressMarkModel *)changeMarkModel{
    _changeMarkModel = changeMarkModel;
}

-(void)textField1TextChange:(GLGWTextField *)textField{
    switch (_row_Num) {
        case 0:{
            _changeMarkModel.lineOneStr = textField.text;
        }
            break;
        case 1:{
            _changeMarkModel.lineTwoStr = textField.text;
        }
            break;
        case 2:{
            _changeMarkModel.lineThreeStr = textField.text;
        }
            break;
            
        default:
            break;
    }
    if (textField.text.length > 0) {
        seePasswordBut.hidden = NO;
    }else{
        seePasswordBut.hidden = YES;
    }
    if (self.Block_ChangeTextField) {
        self.Block_ChangeTextField();
    }
}

-(void)showPassword:(GLGWButton *)sender{
    sender.selected = !sender.selected;
    if (sender.selected) {
        sender.image_Name = @"myinfoe_See";
    }else{
        sender.image_Name = @"myinfor_noSee";
    }
    self.inputTextField.secureTextEntry = !sender.selected;
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
